/*************************************************************************************
* 	 Copyright (C) 2010 by Information Systems Group, Saarland University  			*
*    http://infosys.cs.uni-saarland.de												*
* 	 																				*
* 	 This file is part of Hadoop++.												 	*
*																					*
*    Hadoop++ is free software: you can redistribute it and/or modify				*
*    it under the terms of the GNU Lesser General Public License as published by	*
*    the Free Software Foundation, either version 3 of the License, or				*
*    (at your option) any later version.											*
*																					*
*    Hadoop++ is distributed in the hope that it will be useful,					*
*    but WITHOUT ANY WARRANTY; without even the implied warranty of					*
*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the					*
*    GNU Lesser General Public License for more details.							*
*																					*
*    You should have received a copy of the GNU Lesser General Public License		*
*    along with Hadoop++.  If not, see <http://www.gnu.org/licenses/>.				*
*************************************************************************************/
package unisb.cs.core.index.access;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapred.FileSplit;
import org.apache.hadoop.mapred.InputSplit;
import org.apache.hadoop.mapred.JobConf;
import org.apache.hadoop.mapred.RecordReader;
import org.apache.hadoop.mapred.Reporter;

import unisb.cs.core.binary.reader.BinaryReaderInputFormat;

/**
 * This class provides the input format for accessing the indexed data. 
 *
 */
public class IndexAccesserInputFormat extends BinaryReaderInputFormat {

	/** index attributes */ 
	public static String IDX_ATTR = "idxattr";
	public static String IDX_ATTR_SIZE = "idxattrsize";
	public static String IDX_ATTR_TYPE = "idxattrtype";

	/** the low and high index lookup keys */
	public static String LOW_KEY = "lowkey";
	public static String HIGH_KEY = "highkey";

	/**
	 * Record reader to process the split data using index access.
	 */
	@Override
	public RecordReader<Text, Text> getRecordReader(InputSplit split, JobConf conf, Reporter r) {
		try {
			return new IndexAccesserRecordReader((FileSplit) split, conf);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return null;
	}
}
